<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.cn.util.SqlsesstionUtil" %>
<%@ page import="com.cn.Mapper.vipMapper.VipcustomerMapper" %>
<%@ page import="com.cn.entity.vip.Vipcustomer" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cn.entity.vip.Vipcustomer_Search" %><%--
  Created by IntelliJ IDEA.
  User: yujiajing
  Date: 2022/10/10
  Time: 21:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>vip表</title>
    <%--  引入jQuery包  --%>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>

    <!-- 引入layui css -->
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" />

    <!-- 引入layui js -->
    <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
</head>
<style type="text/css">
    #CardId{
        width: 200px;
        height: 40px;
        float:left;
    }
</style>
<body>

<%
  SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
  VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
  List<Vipcustomer> vipcustomerList = vipcustomerMapper.selectVipcustomer();
%>
<%--显示模块--%>
<div>
    <table id="UserTable" class="layui-table"  >
        <tr>
            <td>ID</td>
            <td>名字</td>
            <td>会员积分</td>
            <td>卡号</td>
            <td>会员等级</td>
            <td>密码</td>
            <td>电话</td>


        </tr>

        <%for (Vipcustomer vipcustomer:vipcustomerList){%>
        <%--  --%>
        <tr id="tr_<%=vipcustomer.getCard_id()%>">
            <%--    --%>
            <td><%=vipcustomer.getVip_id()%></td>
            <td><%=vipcustomer.getVip_name()%></td>
            <td><%=vipcustomer.getvip_point()%></td>
            <td><%=vipcustomer.getCard_id()%></td>
            <td><%=vipcustomer.getCard_grade()%></td>
            <td><%=vipcustomer.getVip_password()%></td>
            <td><%=vipcustomer.getvip_mobilephone()%></td>
            <td>
                <a class="layui-btn layui-btn-xs" lay-event="edit" href="">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs"  href="">删除</a>
            </td>
            <%}%>
        </tr >
    </table>
</div>


<%--查询模块--%>
<div>
    <button class="layui-btn layui-btn-normal" id="search" type="submit" onclick=getCartId()>查询</button>
    <input type="text" id="CardId" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">


</div>
<%--查询模块--%>
<div>
    <table id="searchTable" class="layui-table"  >
        <tr>
            <td>ID</td>
            <td>名字</td>
            <td>会员积分</td>
            <td>卡号</td>
            <td>会员等级</td>
            <td>密码</td>
            <td>电话</td>


        </tr>
        <%
            SqlSession sqlSession1 = SqlsesstionUtil.getSqlSession();
            VipcustomerMapper vipcustomerMapper1 = sqlSession1.getMapper(VipcustomerMapper.class);
            List<Vipcustomer_Search> searchList = vipcustomerMapper1.showSearch();
        %>
        <%for (Vipcustomer vipcustomer:searchList){%>
        <%--  --%>
        <tr id="tr_<%=vipcustomer.getCard_id()%>">
            <%--    --%>
            <td><%=vipcustomer.getVip_id()%></td>
            <td><%=vipcustomer.getVip_name()%></td>
            <td><%=vipcustomer.getvip_point()%></td>
            <td><%=vipcustomer.getCard_id()%></td>
            <td><%=vipcustomer.getCard_grade()%></td>
            <td><%=vipcustomer.getVip_password()%></td>
            <td><%=vipcustomer.getvip_mobilephone()%></td>

            <%}%>
        </tr >
    </table>
</div>

<script type="text/javascript">

function getCartId(){
    var Card_id=document.getElementById("CardId").value;
    search(Card_id);
}

    function search(Card_id) {

        $.ajax({

            type: "post",

            url: "vip/search",

            dateType: "String",

            data: {

                Card_id: Card_id
            },

            success: function () {
                alert("查询成功！");
                location.reload();
            },


        });

    }

</script>
</body>
</html>


<%--

var html = "";
//搜索的标头部分
html += "<table  class='layui-table' >";
html += "<tr>";

html += "<td>";
html += "ID";
html += "</td>";



html += "<td>";
html += "名字";
html += "</td>";

html += "<td>";
html += "会员积分";
html += "</td>";

html += "<td>";
html += "卡号";
html += "</td>";

html += "<td>";
html += "会员等级";
html += "</td>";

html += "<td>";
html += "密码";
html += "</td>";

html += "<td>";
html += "电话";
html += "</td>";

html += "</tr>"



<%for (Vipcustomer_Search vipcustomer:searchList){%>

html+="<tr>";
html+= "<td><%=vipcustomer.getVip_id()%></td>";
html+=  "<td><%=vipcustomer.getVip_name()%></td>";
html+=   "<td><%=vipcustomer.getvip_point()%></td>";
html+=  " <td><%=vipcustomer.getCard_id()%></td>";
html+=   " <td><%=vipcustomer.getCard_grade()%></td>";
html+=   "<td><%=vipcustomer.getVip_password()%></td>";
html+=   "<td><%=vipcustomer.getvip_mobilephone()%></td>";
html+= "</tr >";

html += "</table>"
<%}%>

$("#search").append(html);--%>
